Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: Drop keyValue field in metrics.Tag; normalizeTag short-circuits simple strings #324

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

bmoylan
Copy link
Contributor

@bmoylan bmoylan commented Sep 8, 2023

pkg: github.com/palantir/pkg/metrics
                                                 │   old.txt    │              new.txt               │
                                                 │    sec/op    │   sec/op     vs base               │
NewTag/tagLen:2-10                                  59.86n ± 2%   12.11n ± 1%  -79.77% (p=0.001 n=7)
NewTag/tagLen:10-10                                 91.77n ± 1%   15.65n ± 1%  -82.95% (p=0.001 n=7)
NewTag/tagLen:100-10                               414.10n ± 1%   83.79n ± 1%  -79.77% (p=0.001 n=7)
NewTag/tagLen:199-10                                745.8n ± 2%   174.2n ± 1%  -76.64% (p=0.001 n=7)
NormalizeTag/a❌Long❌Tag❌With❌Emoji❌Chars-10    273.6n ± 3%   223.8n ± 1%  -18.20% (p=0.001 n=7)
NormalizeTag/a_Long_Tag_With_Space_Chars-10         195.3n ± 1%   145.7n ± 1%  -25.40% (p=0.001 n=7)
NormalizeTag/aLongTagValueWithUpperChars-10         168.5n ± 1%   118.1n ± 1%  -29.91% (p=0.001 n=7)
NormalizeTag/alongtagvaluewithnospecials-10        169.10n ± 1%   30.06n ± 1%  -82.22% (p=0.001 n=7)
NormalizeTag/UPPER-10                               90.60n ± 1%   40.59n ± 1%  -55.20% (p=0.001 n=7)
NormalizeTag/lower-10                               90.50n ± 0%   14.40n ± 1%  -84.09% (p=0.001 n=7)
RegisterMetric/1_tag-10                             93.79n ± 1%   99.51n ± 1%   +6.10% (p=0.001 n=7)
RegisterMetric/10_tag-10                            265.7n ± 1%   305.2n ± 2%  +14.87% (p=0.001 n=7)
RegisterMetric/100_tag-10                           6.866µ ± 2%   5.579µ ± 2%  -18.74% (p=0.001 n=7)
Histogram/HistogramWithSample_with_cached_Tag-10    263.8n ± 1%   263.9n ± 1%        ~ (p=0.925 n=7)
Histogram/Histogram_with_cached_Tag-10              244.1n ± 1%   242.8n ± 1%        ~ (p=0.119 n=7)
Histogram/HistogramWithSample_with_NewTag-10        378.8n ± 1%   287.4n ± 1%  -24.13% (p=0.001 n=7)
Histogram/Histogram_with_NewTag-10                  353.3n ± 4%   263.8n ± 4%  -25.33% (p=0.001 n=7)
Histogram/cached_Histogram-10                       126.6n ± 1%   127.5n ± 1%        ~ (p=0.156 n=7)
geomean                                             232.5n        118.0n       -49.26%

                                                 │    old.txt     │                 new.txt                  │
                                                 │      B/op      │     B/op      vs base                    │
NewTag/tagLen:2-10                                   5.000 ± 0%       0.000 ± 0%  -100.00% (p=0.001 n=7)
NewTag/tagLen:10-10                                  24.00 ± 0%        0.00 ± 0%  -100.00% (p=0.001 n=7)
NewTag/tagLen:100-10                                 240.0 ± 0%         0.0 ± 0%  -100.00% (p=0.001 n=7)
NewTag/tagLen:199-10                                 432.0 ± 0%         0.0 ± 0%  -100.00% (p=0.001 n=7)
NormalizeTag/a❌Long❌Tag❌With❌Emoji❌Chars-10     83.00 ± 0%       48.00 ± 0%   -42.17% (p=0.001 n=7)
NormalizeTag/a_Long_Tag_With_Space_Chars-10          67.00 ± 0%       32.00 ± 0%   -52.24% (p=0.001 n=7)
NormalizeTag/aLongTagValueWithUpperChars-10          67.00 ± 0%       32.00 ± 0%   -52.24% (p=0.001 n=7)
NormalizeTag/alongtagvaluewithnospecials-10          67.00 ± 0%        0.00 ± 0%  -100.00% (p=0.001 n=7)
NormalizeTag/UPPER-10                               21.000 ± 0%       5.000 ± 0%   -76.19% (p=0.001 n=7)
NormalizeTag/lower-10                                21.00 ± 0%        0.00 ± 0%  -100.00% (p=0.001 n=7)
RegisterMetric/1_tag-10                              72.00 ± 0%       56.00 ± 0%   -22.22% (p=0.001 n=7)
RegisterMetric/10_tag-10                             592.0 ± 0%       432.0 ± 0%   -27.03% (p=0.001 n=7)
RegisterMetric/100_tag-10                          6.000Ki ± 0%     4.375Ki ± 0%   -27.08% (p=0.001 n=7)
Histogram/HistogramWithSample_with_cached_Tag-10     184.0 ± 0%       152.0 ± 0%   -17.39% (p=0.001 n=7)
Histogram/Histogram_with_cached_Tag-10               160.0 ± 0%       128.0 ± 0%   -20.00% (p=0.001 n=7)
Histogram/HistogramWithSample_with_NewTag-10         205.0 ± 0%       152.0 ± 0%   -25.85% (p=0.001 n=7)
Histogram/Histogram_with_NewTag-10                   181.0 ± 0%       128.0 ± 0%   -29.28% (p=0.001 n=7)
Histogram/cached_Histogram-10                        0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=7) ¹
geomean                                                         ²                 ?                      ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean

                                                 │   old.txt    │                new.txt                 │
                                                 │  allocs/op   │ allocs/op   vs base                    │
NewTag/tagLen:2-10                                 3.000 ± 0%     0.000 ± 0%  -100.00% (p=0.001 n=7)
NewTag/tagLen:10-10                                3.000 ± 0%     0.000 ± 0%  -100.00% (p=0.001 n=7)
NewTag/tagLen:100-10                               3.000 ± 0%     0.000 ± 0%  -100.00% (p=0.001 n=7)
NewTag/tagLen:199-10                               3.000 ± 0%     0.000 ± 0%  -100.00% (p=0.001 n=7)
NormalizeTag/a❌Long❌Tag❌With❌Emoji❌Chars-10   3.000 ± 0%     1.000 ± 0%   -66.67% (p=0.001 n=7)
NormalizeTag/a_Long_Tag_With_Space_Chars-10        3.000 ± 0%     1.000 ± 0%   -66.67% (p=0.001 n=7)
NormalizeTag/aLongTagValueWithUpperChars-10        3.000 ± 0%     1.000 ± 0%   -66.67% (p=0.001 n=7)
NormalizeTag/alongtagvaluewithnospecials-10        3.000 ± 0%     0.000 ± 0%  -100.00% (p=0.001 n=7)
NormalizeTag/UPPER-10                              3.000 ± 0%     1.000 ± 0%   -66.67% (p=0.001 n=7)
NormalizeTag/lower-10                              3.000 ± 0%     0.000 ± 0%  -100.00% (p=0.001 n=7)
RegisterMetric/1_tag-10                            2.000 ± 0%     2.000 ± 0%         ~ (p=1.000 n=7) ¹
RegisterMetric/10_tag-10                           2.000 ± 0%     2.000 ± 0%         ~ (p=1.000 n=7) ¹
RegisterMetric/100_tag-10                          2.000 ± 0%     2.000 ± 0%         ~ (p=1.000 n=7) ¹
Histogram/HistogramWithSample_with_cached_Tag-10   4.000 ± 0%     4.000 ± 0%         ~ (p=1.000 n=7) ¹
Histogram/Histogram_with_cached_Tag-10             3.000 ± 0%     3.000 ± 0%         ~ (p=1.000 n=7) ¹
Histogram/HistogramWithSample_with_NewTag-10       7.000 ± 0%     4.000 ± 0%   -42.86% (p=0.001 n=7)
Histogram/Histogram_with_NewTag-10                 6.000 ± 0%     3.000 ± 0%   -50.00% (p=0.001 n=7)
Histogram/cached_Histogram-10                      0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=7) ¹
geomean                                                       ²               ?                      ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean

This change is Reviewable

@bmoylan bmoylan changed the title improvement: Drop keyValue field in metrics.Tag improvement: Drop keyValue field in metrics.Tag; normalizeTag short-circuits simple strings Sep 8, 2023
@bmoylan bmoylan requested review from dtrejod and splucs September 8, 2023 16:49
@bulldozer-bot bulldozer-bot bot merged commit 69bf2e9 into master Sep 8, 2023
@bulldozer-bot bulldozer-bot bot deleted the bm/remove-keyvalue branch September 8, 2023 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants